package modele;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		AFN afn = new AFN();
		State s1 = new SimpleState("1");
		State s2 = new SimpleState("2");

		afn.addState(s1);
		afn.addState(s2);

		Symbol a = new Letter('a');
		Symbol b = new Letter('b');

		afn.setInitial(s1);
		afn.setInitial(s2);
		afn.setFinal(s2);

		afn.addTransition(s1, a, s2);
		afn.addTransition(s2, b, s2);

		afn.displayAFN();
		
		ArrayList<String> liste = new ArrayList<String>();
		liste.add("a");
		liste.add("ab");
		liste.add("aba");
		liste.add("abbb");

		for (String word : liste)
			System.out.println(word + " : " + afn.accept(word));

		// ---------------------------

		AFN afnb = new AFN();
		State sb1 = new SimpleState("1");
		State sb2 = new SimpleState("2");
		State sb3 = new SimpleState("3");
		State sb4 = new SimpleState("4");
		State sb5 = new SimpleState("5");

		afnb.addState(sb1);
		afnb.addState(sb2);
		afnb.addState(sb3);
		afnb.addState(sb4);
		afnb.addState(sb5);

		Symbol c = new Letter('c');

		afnb.setInitial(sb1);
		afnb.setFinal(sb3);
		afnb.setFinal(sb4);

		afnb.addTransition(sb1, a, sb2);
		afnb.addTransition(sb1, c, sb5);
		afnb.addTransition(sb2, b, sb2);
		afnb.addTransition(sb2, a, sb3);
		afnb.addTransition(sb3, a, sb2);
		afnb.addTransition(sb3, b, sb3);
		afnb.addTransition(sb3, c, sb4);
		afnb.addTransition(sb5, a, sb5);
		afnb.addTransition(sb5, b, sb5);
		afnb.addTransition(sb5, c, sb4);

		afnb.displayAFN();

		ArrayList<String> listeb = new ArrayList<String>();
		listeb.add("aa");
		listeb.add("abbba");
		listeb.add("ababc");
		listeb.add("ababc");
		listeb.add("cbaa");
		listeb.add("abbaaa");
		listeb.add("cbaababac");

		for (String word : listeb)
			System.out.println(word + " : " + afnb.accept(word));

		Scanner sc = new Scanner(System.in);
		String word;
		do {
			word = sc.nextLine();
			System.out.println(word + " : " + afnb.accept(word));
		} while (!word.equals(""));

	}
}
